<?php
	require_once('settings.php');
	require_once('classes/db.php');
	require_once('classes/functions.php');
	
	$demoid = sanitizeString($_REQUEST['did']);
	
	$demo_query = "SELECT filename FROM sm_demos WHERE id='$demoid';";
	$demo_result = mysql_query($demo_query) or die(mysql_error());
	$demo_array = mysql_fetch_array($demo_result);
	$filename = $demo_array['filename'];
	
	header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
	header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
	header("Content-type: application/force-download");
	header("Content-Transfer-Encoding: Binary");
	header("Content-disposition: attachment; filename=\"$filename\";");


	
	readfile("demos/$filename");
?>